package com.transino.bop.domain;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

import com.kanas.framework.support.AbstractModel;

@XmlRootElement(name = "option")
public class Option extends AbstractModel implements Cloneable,Comparable<Option> {

	private static final long serialVersionUID = 1L;
	
	private String id;
	private String label;
	private Integer index;
	
	public Option() {
		
	}
	
	public Option(String id, String label) {
		this.id = id;
		this.label = label;
	}
	
	@XmlAttribute(name = "id")
	public String getId() {
		return id;
	}
	
	public void setId(String id) {
		this.id = id;
	}
	
	@XmlAttribute(name = "label")
	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}

	@XmlAttribute(name = "index")
	public Integer getIndex() {
		return index;
	}

	public void setIndex(Integer index) {
		this.index = index;
	}

	@Override
	public int compareTo(Option o) {
		if(this.index==null || o.getIndex()==null) {
			return 1;
		}else {
			return this.index - o.getIndex();
		}
	}

	@Override
	public String toIdString() {
		return this.id;
	}
	
}
